package com.dashu.device.service.HQ;

import com.alibaba.fastjson.JSONObject;
import com.dashu.base.utils.CopyUtil;
import com.dashu.device.api.HQ.HQInsideServerApi;
import com.dashu.device.bean.JL.JLHeartBean;
import com.dashu.device.cache.CommomLocalCache;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


@Slf4j
@Service
public class HQInsideInsideService<T>   implements HQInsideServerApi<T>
{


    @Override
    public void heartbeat(ChannelHandlerContext ctx, Object object,long cacheTime) {
       JLHeartBean jlHeartBean =  CopyUtil.copyEnty(object,JLHeartBean.class) ;
        CommomLocalCache.putTime(jlHeartBean.getDeviceUUID(), jlHeartBean,cacheTime);
    }

    @Override
    public void compared(ChannelHandlerContext ctx, Object o, String msg) {
        JSONObject userJson = JSONObject.parseObject(msg);
        System.out.println(userJson);
    }
}
